package hlhj.fhp.checkpoint.utils

import java.text.ParseException
import java.text.SimpleDateFormat
import java.util.*


/**
 * Created by Never Fear   on 2018\11\28 0028.
Never More....
 */
object TimeUtil {
    /*
     * 将时间转换为时间戳
     */
    @Throws(ParseException::class)
    fun dateToStamp(s: String?): String {
        s?.let {
            val res: String
            val simpleDateFormat = SimpleDateFormat("yyyy-MM-dd HH:mm:ss")
            val date = simpleDateFormat.parse(it)
            val ts = date.getTime()
            res = ts.toString()
            return res
        }
        return ""
    }

    /*
     * 将时间戳转换为时间
     */
    fun stampToDate(s: String): String {
        val res: String
        val simpleDateFormat = SimpleDateFormat("yyyy-MM-dd HH:mm:ss")
        val lt = s.toLong()
        val date = Date(lt)
        res = simpleDateFormat.format(date)
        return res
    }
}